package com.stylefeng.guns.modular.system.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.system.model.ProcesstypeDesc;
import com.stylefeng.guns.modular.system.service.IProcesstypeDescService;

/**
 * 请假类型控制器
 *
 * @author fengshuonan
 * @Date 2019-06-21 11:08:38
 */
@Controller
@RequestMapping("/processtypeDesc")
public class ProcesstypeDescController extends BaseController {

    private String PREFIX = "/system/processtypeDesc/";

    @Autowired
    private IProcesstypeDescService processtypeDescService;

    /**
     * 跳转到请假类型首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "processtypeDesc.html";
    }

    /**
     * 跳转到添加请假类型
     */
    @RequestMapping("/processtypeDesc_add")
    public String processtypeDescAdd() {
        return PREFIX + "processtypeDesc_add.html";
    }

    /**
     * 跳转到修改请假类型
     */
    @RequestMapping("/processtypeDesc_update/{processtypeDescId}")
    public String processtypeDescUpdate(@PathVariable Integer processtypeDescId, Model model) {
        ProcesstypeDesc processtypeDesc = processtypeDescService.selectById(processtypeDescId);
        model.addAttribute("item",processtypeDesc);
        LogObjectHolder.me().set(processtypeDesc);
        return PREFIX + "processtypeDesc_edit.html";
    }

    /**
     * 获取请假类型列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return processtypeDescService.selectList(null);
    }

    /**
     * 新增请假类型
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(ProcesstypeDesc processtypeDesc) {
        processtypeDescService.insert(processtypeDesc);
        return SUCCESS_TIP;
    }

    /**
     * 删除请假类型
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer processtypeDescId) {
        processtypeDescService.deleteById(processtypeDescId);
        return SUCCESS_TIP;
    }

    /**
     * 修改请假类型
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(ProcesstypeDesc processtypeDesc) {
        processtypeDescService.updateById(processtypeDesc);
        return SUCCESS_TIP;
    }

    /**
     * 请假类型详情
     */
    @RequestMapping(value = "/detail/{processtypeDescId}")
    @ResponseBody
    public Object detail(@PathVariable("processtypeDescId") Integer processtypeDescId) {
        return processtypeDescService.selectById(processtypeDescId);
    }
}
